#!/usr/bin/env bash
set -e
mvn clean compile package install -Dmaven.test.skip=true

rm -rf build && mkdir -p build/apps && cp Dockerfile build
cp  start.sh build/apps && cp filebeat.yml build && cp supervisor-apps.conf build && cp target/autopai-work-time.jar build/apps
cd build
if [ -z $1 ]; then
    docker build -t ccr.ccs.tencentyun.com/autopai/autopai-work-time:latest .
    docker push ccr.ccs.tencentyun.com/autopai/autopai-work-time:latest
else
    docker build -t ccr.ccs.tencentyun.com/autopai/autopai-work-time:$1 .
    docker push ccr.ccs.tencentyun.com/autopai/autopai-work-time:$1
fi